package com.tencent.bugly.beta.upgrade;

import android.support.v4.app.NotificationCompat;
import com.tencent.bugly.beta.Beta;
import com.tencent.bugly.beta.global.d;
import com.tencent.bugly.beta.global.e;
import com.tencent.bugly.proguard.aa;
import com.tencent.bugly.proguard.ah;
import com.tencent.bugly.proguard.aj;
import com.tencent.bugly.proguard.an;
import com.tencent.bugly.proguard.bi;
import com.tencent.bugly.proguard.bk;
import com.tencent.bugly.proguard.p;
import com.tencent.bugly.proguard.q;
import com.tencent.bugly.proguard.x;
import com.tencent.bugly.proguard.y;

/* compiled from: BUGLY */
/* loaded from: classes.dex */
public class a implements aj {
    public final int a;
    public final int b;
    public final Object[] c;
    public boolean d = false;

    @Override // com.tencent.bugly.proguard.aj
    public void a(int i) {
    }

    public a(int i, int i2, Object... objArr) {
        this.a = i;
        this.b = i2;
        this.c = objArr;
    }

    @Override // com.tencent.bugly.proguard.aj
    public synchronized void a(int i, bi biVar, long j, long j2, boolean z, String str) {
        y yVar;
        bk bkVar;
        aa aaVar;
        aa aaVar2;
        try {
            if (!this.d && i == this.b) {
                Object[] objArr = new Object[4];
                objArr[0] = z ? "succ" : NotificationCompat.CATEGORY_ERROR;
                objArr[1] = Integer.valueOf(i);
                objArr[2] = Long.valueOf(j);
                objArr[3] = Long.valueOf(j2);
                an.a("upload %s:[%d] [sended %d] [recevied %d]", objArr);
                int i2 = this.a;
                if (i2 == 1) {
                    boolean booleanValue = ((Boolean) this.c[0]).booleanValue();
                    boolean booleanValue2 = ((Boolean) this.c[1]).booleanValue();
                    if (this.b != 804) {
                        return;
                    }
                    y yVar2 = null;
                    if (!z || biVar == null || (aaVar = (aa) ah.a(biVar.c, aa.class)) == null) {
                        yVar = null;
                        bkVar = null;
                    } else {
                        bkVar = aaVar.a;
                        yVar = aaVar.b;
                    }
                    c.a.a(bkVar);
                    BetaGrayStrategy betaGrayStrategy = (BetaGrayStrategy) this.c[2];
                    if (yVar != null) {
                        yVar2 = yVar;
                    } else if (betaGrayStrategy != null) {
                        yVar2 = betaGrayStrategy.a;
                    }
                    if (yVar2 != null) {
                        int i3 = yVar2.p;
                        if (i3 == 1) {
                            c.a.a(booleanValue, booleanValue2, z ? 0 : -1, yVar, str);
                            e.E.ae = 1;
                        } else if (i3 != 2) {
                            if (i3 == 3) {
                                e.E.ae = 3;
                                q.a.a(z ? 0 : -1, yVar, false);
                                if (c.a.f != null) {
                                    com.tencent.bugly.beta.utils.e.a(new d(18, c.a.f, 1, Boolean.valueOf(booleanValue)));
                                } else if (booleanValue && !booleanValue2) {
                                    com.tencent.bugly.beta.utils.e.a(new d(5, Beta.strToastYourAreTheLatestVersion));
                                }
                            } else {
                                an.a("unexpected updatetype", new Object[0]);
                            }
                        }
                    } else {
                        c.a.a(booleanValue, booleanValue2, z ? 0 : -1, null, str);
                    }
                } else if (i2 == 2) {
                    x xVar = (x) this.c[0];
                    if (this.b != 803) {
                        return;
                    }
                    if (z) {
                        if (biVar != null && (aaVar2 = (aa) ah.a(biVar.c, aa.class)) != null) {
                            c.a.a(aaVar2.a);
                        }
                        p.a.b();
                    }
                }
                this.d = true;
            }
        } catch (Exception e) {
            if (!an.b(e)) {
                e.printStackTrace();
            }
        }
    }
}
